<?php

/**
 * Flickr Photosets - Tagged Page
 * Displays photos tagged with a particular user.
 * 
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */

/*
Require the function library
This will include all other necessary files
*/
require_once 'lib.php';

/*
Initialize Flickr Photosets and Flickr.
This will create the Flickr object without using the cache.
	(There is still a delay when you tag sometimes, the tag
	is not always immediately available in a search.)
*/
$fp = new FP_ProfileTab();

// Get photos
$photo_page = (isset($_GET['photo_page'])) ? $_GET['photo_page'] : 1;
$fp->page = $photo_page; // So we get the right page of tagged photos
//$photos = $fp->get_tagged_photos_of($fp->uid);

if ($fp->config['privacy_filter'] == $fp->privacy_filter['private']) {
	$photos = $fp->flickr->photos_search(array(
		'user_id'        => $fp->nsid,
		'per_page'       => 15,
		'page'           => $fp->page,
		'extras'         => 'date_upload, media',
	));
}
else {
	$photos = $fp->flickr->photos_search(array(
		'user_id'        => $fp->nsid,
		'privacy_filter' => $fp->privacy_filter['public'],
		'per_page'       => 15,
		'page'           => $fp->page,
		'extras'         => 'date_upload, media',
	));
}

$photosets = $fp->flickr->photosets_getList($fp->nsid);
$photosets['photoset'] = array_slice($photosets['photoset'], 0, 5);

?>
<pre>
<?=print_r($fp)?>
</pre>

<?php include 'styles.php'; ?>

<div id="photo_header" class="clearfix">
	<div class="summary">
		<?=$fp->get_name_fbml(false, true, false)?> Photostream
		<span class="pipe">|</span>
		<a href="<?=$fp->flickr->urls_getUserPhotos($fp->nsid)?>">View on Flickr</a>
	</div>
	<ul class="pagerpro">
		<li><a href="<?=$fp->canvas_url?>/photos/<?=$fp->uid?>/">See All</a></li>
	</ul>
</div>

<div class="photo_grid">
	<table>
		<tr>
			<?php $i = 0;
			foreach ($photos['photo'] as $photo): ?>
				<td>
					<a href="<?=$fp->canvas_url?>/photos/<?=$fp->uid?>/<?=$photo['id']?>/">
						<div class="thumb">
						<?php if ($photo['media'] == 'video') { ?>
							<img src="http://l.yimg.com/g/images/video_play_icon_medium.png.v1" class="video_icon" />
						<?php } ?>
						<fb:user-agent includes="ie 6">
							<img src="<?=$fp->flickr->buildPhotoUrl($photo, 'thumbnail')?>" alt="<?=$photo['title']?>" title="<?=$photo['title']?>" />
						</fb:user-agent>
						<fb:user-agent excludes="ie 6">
							<img src="<?=$fp->flickr->buildPhotoUrl($photo, 'small')?>" alt="<?=$photo['title']?>" title="<?=$photo['title']?>" />
						</fb:user-agent>
						</div>
					</a>
				</td>
			<?php $i++;
			echo ($i % 5 == 0) ? '</tr><tr>' : ''; ?>
			<?php endforeach; ?>
		</tr>
	</table>	
</div>